var url = urls();
var params = oneValues();
var id = params.id.split("_")[1];

//详情
$.ajax({
    type: "post",
    url: url + "/api/case/case_details",
    data: {
        id: id,
    },
    dataType: "json",
    success: function (res) {
        anli_details(res)
    }
});

//列表
$.ajax({
    type: "post",
    url: url + "/api/statement/hot",
    data: {
        number: 6,
    },
    dataType: "json",
    success: function (res) {
        anli_list(res)
    }
});

function anli_details(res) {
    var arr = res.data;
    var title = arr.post_title;
    var time = arr.published_time;
    var txt = arr.post_content;
    $(".anli_details_title").html(title);
    $(".anli_time").html(time);
    $(".anli_details_txt").html(txt);
    $(".anli_prev").click(function () {
        prev_next("热点话题", arr.create_time, 1);
    })
    $(".anli_next").click(function () {
        prev_next("热点话题", arr.create_time, 2);
    })
}

function anli_list(res) {
    var arr = res.data.data;
    var a = '';
    for (i in arr) {
        a += '<li><a href="' + url + '/portal/index/hot.html?id=topics_' + arr[i].id + '">' + arr[i].post_title + '</a></li>';
    }
    $(".anli_relevant_list").html(a);
}

function prev_next(name, time, type) {
    $.ajax({
        type: "post",
        url: url + "/api/case/up_down",
        data: {
            name: name,
            time: time,
            type: type
        },
        dataType: "json",
        success: function (res) {
            var arr = res.data;
            if (arr.post_content == "" && type == "1") {
                layer.msg("当前是第一篇！")
            } else if (arr.post_content == "" && type == "2") {
                layer.msg("当前是最后一篇！")
            } else {
                window.location.href = url + "/portal/index/hot.html?id=topics_" + arr.id;
            }
        }
    });
}
